# coding=utf-8
"""
作者：董新强 
创建时间：2020-5-8
描述：报告管理
"""

from db_models.apps.app_cat_test import AppCatTest as Test
from framework.db_session import DbSession
from framework.msg import ok, failure


class ScoreManage():
    def __init__(self, appid):
        self.appid = appid

    def get_score(self, test_id):
        with DbSession.create() as db:
            test = db.query(Test.id, Test.score, Test.status) \
                .filter(Test.id == test_id) \
                .filter(Test.appid == self.appid).first()
            if not test: return failure(msg='查无结果')
            return ok(data={
                'id': test[0],
                'score': test[1],
                'status': test[2]
            })


if __name__ == '__main__':
    pass
